/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package assisisw.smartcal.webuisubsystem.managedbean.calendar;

import assisisw.smartcal.entitysubsystem.Calendar;
import assisisw.smartcal.entitysubsystem.ICalendarController;
import assisisw.smartcal.entitysubsystem.User;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.inject.Named;
 
/**
 *
 * @author Francesco
 */
@ManagedBean ( eager = true ) 
@Named ( value = "newCalendarControllerBean" )
@ViewScoped ()
public class NewCalendarControllerBean extends AbstractCalendarControllerBean
{

    // Instance Methods
    
    /***/
    public NewCalendarControllerBean () 
    {
        super () ;
    }
   
    /**
     * AS THE SUPER'S ONE.
     */
    @Override
    public void calendarViewConfirmationCommand () 
    {
        User user ; 
        Calendar calendar ;
        ICalendarController controller ;
        controller = getCalendarController(); 
        calendar = getManagedCalendar() ;
        user = getDashboardBean().getManagedUser();
        controller.insert(calendar, user) ;
        getDashboardBean().onNewCalendarInserted(calendar); 
        
    }
    
    /***/
    public void setNewManagedCalendar () 
    {
        setManagedCalendar ( new Calendar () ) ;
        setCalendarEditable(true); 
    }
    
}
